package cn.wolfcode.luowowo.article.service.impl;

import cn.wolfcode.luowowo.article.domain.StrategyCommend;
import cn.wolfcode.luowowo.article.domain.TravelCommend;
import cn.wolfcode.luowowo.article.mapper.StrategyCommendMapper;
import cn.wolfcode.luowowo.article.mapper.TravelCommendMapper;
import cn.wolfcode.luowowo.article.query.StrategyCommendQuery;
import cn.wolfcode.luowowo.article.query.TravelCommendQuery;
import cn.wolfcode.luowowo.article.service.IStrategyCommendService;
import cn.wolfcode.luowowo.article.service.ITravelCommendService;
import com.alibaba.dubbo.config.annotation.Service;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

@Service
public class TravelCommendServiceImpl implements ITravelCommendService {
    @Autowired
    private TravelCommendMapper travelCommendMapper;
    @Override
    public int deleteByPrimaryKey(Long id) {
        return travelCommendMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int insert(TravelCommend travelCommend) {
        return travelCommendMapper.insert(travelCommend);
    }

    @Override
    public TravelCommend selectByPrimaryKey(Long id) {
        return travelCommendMapper.selectByPrimaryKey(id);
    }

    @Override
    public List<TravelCommend> selectAll() {
        return travelCommendMapper.selectAll();
    }

    @Override
    public int updateByPrimaryKey(TravelCommend travelCommend) {
        return travelCommendMapper.updateByPrimaryKey(travelCommend);
    }

    @Override
    public PageInfo<TravelCommend> query(TravelCommendQuery qo) {
        PageHelper.startPage(qo.getCurrentPage(),qo.getPageSize());
        List<TravelCommend> list = travelCommendMapper.QueryForList(qo);
        return new PageInfo(list);
    }

    @Override
    public void saveOrUpdate(TravelCommend travelCommend) {
        if (travelCommend.getId()==null){
            travelCommendMapper.insert(travelCommend);
        }else {
            travelCommendMapper.updateByPrimaryKey(travelCommend);
        }
    }

    @Override
    public List<TravelCommend> getHot5() {
        return travelCommendMapper.getHot5();
    }
}
